• personal_time_table_dml.php
  • project /
1 <?php
2
3 // Data functions (insert, update, delete, form)
for table personal_time_table
4
5 // This script and data application were generated
by AppGini 5.72
6 // Download AppGini
for free from https://bigprof.com/appgini/download/
7
8 function personal_time_table_insert(){
9     
global $Translation;
10
11     
// mm: can member insert record?
12     $arrPerm=getTablePermissions(
'personal_time_table');
13     
if(!$arrPerm[1]){
14         
return false;
15     }
16
17     $data[
'day'] = makeSafe($_REQUEST['day']);
18         
if($data['day'] == empty_lookup_value){ $data['day'] = ''; }
19     $data[
'time_start'] = makeSafe($_REQUEST['time_start']);
20         
if($data['time_start'] == empty_lookup_value){ $data['time_start'] = ''; }
21     $data[
'time_start'] = time24($data['time_start']);
22     $data[
'time_end'] = makeSafe($_REQUEST['time_end']);
23         
if($data['time_end'] == empty_lookup_value){ $data['time_end'] = ''; }
24     $data[
'time_end'] = time24($data['time_end']);
25     $data[
'activity'] = makeSafe($_REQUEST['activity']);
26         
if($data['activity'] == empty_lookup_value){ $data['activity'] = ''; }
27     
if($data['day']== ''){
28         echo StyleSheet() .
"\n\n<div class=\"alert alert-danger\">" . $Translation['error:'] . " 'Day': " . $Translation['field not null'] . '<br><br>';
29         echo
'<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
30         exit;
31     }
32     
if($data['time_start']== ''){
33         echo StyleSheet() .
"\n\n<div class=\"alert alert-danger\">" . $Translation['error:'] . " 'Time Start': " . $Translation['field not null'] . '<br><br>';
34         echo
'<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
35         exit;
36     }
37     
if($data['time_end']== ''){
38         echo StyleSheet() .
"\n\n<div class=\"alert alert-danger\">" . $Translation['error:'] . " 'Time End': " . $Translation['field not null'] . '<br><br>';
39         echo
'<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
40         exit;
41     }
42     
if($data['activity']== ''){
43         echo StyleSheet() .
"\n\n<div class=\"alert alert-danger\">" . $Translation['error:'] . " 'Activity': " . $Translation['field not null'] . '<br><br>';
44         echo
'<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
45         exit;
46     }
47
48     
// hook: personal_time_table_before_insert
49     
if(function_exists('personal_time_table_before_insert')){
50         $args=array();
51         
if(!personal_time_table_before_insert($data, getMemberInfo(), $args)){ return false; }
52     }
53
54     $o = array(
'silentErrors' => true);
55     sql(
'insert into `personal_time_table` set `day`=' . (($data['day'] !== '' && $data['day'] !== NULL) ? "'{$data['day']}'" : 'NULL') . ', `time_start`=' . (($data['time_start'] !== '' && $data['time_start'] !== NULL) ? "'{$data['time_start']}'" : 'NULL') . ', `time_end`=' . (($data['time_end'] !== '' && $data['time_end'] !== NULL) ? "'{$data['time_end']}'" : 'NULL') . ', `activity`=' . (($data['activity'] !== '' && $data['activity'] !== NULL) ? "'{$data['activity']}'" : 'NULL'), $o);
56     
if($o['error']!=''){
57         echo $o[
'error'];
58         echo
"<a href=\"personal_time_table_view.php?addNew_x=1\">{$Translation['< back']}</a>";
59         exit;
60     }
61
62     $recID = db_insert_id(db_link());
63
64     
// hook: personal_time_table_after_insert
65     
if(function_exists('personal_time_table_after_insert')){
66         $res = sql(
"select * from `personal_time_table` where `id`='" . makeSafe($recID, false) . "' limit 1", $eo);
67         
if($row = db_fetch_assoc($res)){
68             $data = array_map(
'makeSafe', $row);
69         }
70         $data[
'selectedID'] = makeSafe($recID, false);
71         $args=array();
72         
if(!personal_time_table_after_insert($data, getMemberInfo(), $args)){ return $recID; }
73     }
74
75     
// mm: save ownership data
76     set_record_owner(
'personal_time_table', $recID, getLoggedMemberID());
77
78     
return $recID;
79 }
80
81 function personal_time_table_delete($selected_id, $AllowDeleteOfParents=
false, $skipChecks=false){
82     
// insure referential integrity ...
83     
global $Translation;
84     $selected_id=makeSafe($selected_id);
85
86     
// mm: can member delete record?
87     $arrPerm=getTablePermissions(
'personal_time_table');
88     $ownerGroupID=sqlValue(
"select groupID from membership_userrecords where tableName='personal_time_table' and pkValue='$selected_id'");
89     $ownerMemberID=sqlValue(
"select lcase(memberID) from membership_userrecords where tableName='personal_time_table' and pkValue='$selected_id'");
90     
if(($arrPerm[4]==1 && $ownerMemberID==getLoggedMemberID()) || ($arrPerm[4]==2 && $ownerGroupID==getLoggedGroupID()) || $arrPerm[4]==3){ // allow delete?
91         
// delete allowed, so continue ...
92     }
else{
93         
return $Translation['You don\'t have enough permissions to delete this record'];
94     }
95
96     
// hook: personal_time_table_before_delete
97     
if(function_exists('personal_time_table_before_delete')){
98         $args=array();
99         
if(!personal_time_table_before_delete($selected_id, $skipChecks, getMemberInfo(), $args))
100             
return $Translation['Couldn\'t delete this record'];
101     }
102
103     sql(
"delete from `personal_time_table` where `id`='$selected_id'", $eo);
104
105     
// hook: personal_time_table_after_delete
106     
if(function_exists('personal_time_table_after_delete')){
107         $args=array();
108         personal_time_table_after_delete($selected_id, getMemberInfo(), $args);
109     }
110
111     
// mm: delete ownership data
112     sql(
"delete from membership_userrecords where tableName='personal_time_table' and pkValue='$selected_id'", $eo);
113 }
114
115 function personal_time_table_update($selected_id){
116     
global $Translation;
117
118     
// mm: can member edit record?
119     $arrPerm=getTablePermissions(
'personal_time_table');
120     $ownerGroupID=sqlValue(
"select groupID from membership_userrecords where tableName='personal_time_table' and pkValue='".makeSafe($selected_id)."'");
121     $ownerMemberID=sqlValue(
"select lcase(memberID) from membership_userrecords where tableName='personal_time_table' and pkValue='".makeSafe($selected_id)."'");
122     
if(($arrPerm[3]==1 && $ownerMemberID==getLoggedMemberID()) || ($arrPerm[3]==2 && $ownerGroupID==getLoggedGroupID()) || $arrPerm[3]==3){ // allow update?
123         
// update allowed, so continue ...
124     }
else{
125         
return false;
126     }
127
128     $data[
'day'] = makeSafe($_REQUEST['day']);
129         
if($data['day'] == empty_lookup_value){ $data['day'] = ''; }
130     
if($data['day']==''){
131         echo StyleSheet() .
"\n\n<div class=\"alert alert-danger\">{$Translation['error:']} 'Day': {$Translation['field not null']}<br><br>";
132         echo
'<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
133         exit;
134     }
135     $data[
'time_start'] = makeSafe($_REQUEST['time_start']);
136         
if($data['time_start'] == empty_lookup_value){ $data['time_start'] = ''; }
137     $data[
'time_start'] = time24($data['time_start']);
138     
if($data['time_start']==''){
139         echo StyleSheet() .
"\n\n<div class=\"alert alert-danger\">{$Translation['error:']} 'Time Start': {$Translation['field not null']}<br><br>";
140         echo
'<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
141         exit;
142     }
143     $data[
'time_end'] = makeSafe($_REQUEST['time_end']);
144         
if($data['time_end'] == empty_lookup_value){ $data['time_end'] = ''; }
145     $data[
'time_end'] = time24($data['time_end']);
146     
if($data['time_end']==''){
147         echo StyleSheet() .
"\n\n<div class=\"alert alert-danger\">{$Translation['error:']} 'Time End': {$Translation['field not null']}<br><br>";
148         echo
'<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
149         exit;
150     }
151     $data[
'activity'] = makeSafe($_REQUEST['activity']);
152         
if($data['activity'] == empty_lookup_value){ $data['activity'] = ''; }
153     
if($data['activity']==''){
154         echo StyleSheet() .
"\n\n<div class=\"alert alert-danger\">{$Translation['error:']} 'Activity': {$Translation['field not null']}<br><br>";
155         echo
'<a href="" onclick="history.go(-1); return false;">'.$Translation['< back'].'</a></div>';
156         exit;
157     }
158     $data[
'selectedID']=makeSafe($selected_id);
159
160     
// hook: personal_time_table_before_update
161     
if(function_exists('personal_time_table_before_update')){
162         $args=array();
163         
if(!personal_time_table_before_update($data, getMemberInfo(), $args)){ return false; }
164     }
165
166     $o=array(
'silentErrors' => true);
167     sql(
'update `personal_time_table` set `day`=' . (($data['day'] !== '' && $data['day'] !== NULL) ? "'{$data['day']}'" : 'NULL') . ', `time_start`=' . (($data['time_start'] !== '' && $data['time_start'] !== NULL) ? "'{$data['time_start']}'" : 'NULL') . ', `time_end`=' . (($data['time_end'] !== '' && $data['time_end'] !== NULL) ? "'{$data['time_end']}'" : 'NULL') . ', `activity`=' . (($data['activity'] !== '' && $data['activity'] !== NULL) ? "'{$data['activity']}'" : 'NULL') . " where `id`='".makeSafe($selected_id)."'", $o);
168     
if($o['error']!=''){
169         echo $o[
'error'];
170         echo
'<a href="personal_time_table_view.php?SelectedID='.urlencode($selected_id)."\">{$Translation['< back']}</a>";
171         exit;
172     }
173
174
175     
// hook: personal_time_table_after_update
176     
if(function_exists('personal_time_table_after_update')){
177         $res = sql(
"SELECT * FROM `personal_time_table` WHERE `id`='{$data['selectedID']}' LIMIT 1", $eo);
178         
if($row = db_fetch_assoc($res)){
179             $data = array_map(
'makeSafe', $row);
180         }
181         $data[
'selectedID'] = $data['id'];
182         $args = array();
183         
if(!personal_time_table_after_update($data, getMemberInfo(), $args)){ return; }
184     }
185
186     
// mm: update ownership data
187     sql(
"update membership_userrecords set dateUpdated='".time()."' where tableName='personal_time_table' and pkValue='".makeSafe($selected_id)."'", $eo);
188
189 }
190
191 function personal_time_table_form($selected_id =
'', $AllowUpdate = 1, $AllowInsert = 1, $AllowDelete = 1, $ShowCancel = 0, $TemplateDV = '', $TemplateDVP = ''){
192     
// function to return an editable form for a table records
193     
// and fill it with data of record whose ID is $selected_id. If $selected_id
194     
// is empty, an empty form is shown, with only an 'Add New'
195     
// button displayed.
196
197     
global $Translation;
198
199     
// mm: get table permissions
200     $arrPerm=getTablePermissions(
'personal_time_table');
201     
if(!$arrPerm[1] && $selected_id==''){ return ''; }
202     $AllowInsert = ($arrPerm[
1] ? true : false);
203     
// print preview?
204     $dvprint =
false;
205     
if($selected_id && $_REQUEST['dvprint_x'] != ''){
206         $dvprint =
true;
207     }
208
209
210     
// populate filterers, starting from children to grand-parents
211
212     
// unique random identifier
213     $rnd1 = ($dvprint ? rand(
1000000, 9999999) : '');
214     
// combobox: day
215     $combo_day =
new Combo;
216     $combo_day->ListType =
0;
217     $combo_day->MultipleSeparator =
', ';
218     $combo_day->ListBoxHeight =
10;
219     $combo_day->RadiosPerLine =
1;
220     
if(is_file(dirname(__FILE__).'/hooks/personal_time_table.day.csv')){
221         $day_data = addslashes(implode(
'', @file(dirname(__FILE__).'/hooks/personal_time_table.day.csv')));
222         $combo_day->ListItem = explode(
'||', entitiesToUTF8(convertLegacyOptions($day_data)));
223         $combo_day->ListData = $combo_day->ListItem;
224     }
else{
225         $combo_day->ListItem = explode(
'||', entitiesToUTF8(convertLegacyOptions("Monday;;Tuesday;;Wednesday;;Thursday;;Friday;;Saturday;;Sunday")));
226         $combo_day->ListData = $combo_day->ListItem;
227     }
228     $combo_day->SelectName =
'day';
229     $combo_day->AllowNull =
false;
230
231     
if($selected_id){
232         
// mm: check member permissions
233         
if(!$arrPerm[2]){
234             
return "";
235         }
236         
// mm: who is the owner?
237         $ownerGroupID=sqlValue(
"select groupID from membership_userrecords where tableName='personal_time_table' and pkValue='".makeSafe($selected_id)."'");
238         $ownerMemberID=sqlValue(
"select lcase(memberID) from membership_userrecords where tableName='personal_time_table' and pkValue='".makeSafe($selected_id)."'");
239         
if($arrPerm[2]==1 && getLoggedMemberID()!=$ownerMemberID){
240             
return "";
241         }
242         
if($arrPerm[2]==2 && getLoggedGroupID()!=$ownerGroupID){
243             
return "";
244         }
245
246         
// can edit?
247         
if(($arrPerm[3]==1 && $ownerMemberID==getLoggedMemberID()) || ($arrPerm[3]==2 && $ownerGroupID==getLoggedGroupID()) || $arrPerm[3]==3){
248             $AllowUpdate=
1;
249         }
else{
250             $AllowUpdate=
0;
251         }
252
253         $res = sql(
"select * from `personal_time_table` where `id`='".makeSafe($selected_id)."'", $eo);
254         
if(!($row = db_fetch_array($res))){
255             
return error_message($Translation['No records found'], 'personal_time_table_view.php', false);
256         }
257         $urow = $row;
/* unsanitized data */
258         $hc =
new CI_Input();
259         $row = $hc->xss_clean($row);
/* sanitize data */
260         $combo_day->SelectedData = $row[
'day'];
261     }
else{
262         $combo_day->SelectedText = ( $_REQUEST[
'FilterField'][1]=='2' && $_REQUEST['FilterOperator'][1]=='<=>' ? (get_magic_quotes_gpc() ? stripslashes($_REQUEST['FilterValue'][1]) : $_REQUEST['FilterValue'][1]) : "");
263     }
264     $combo_day->Render();
265
266     ob_start();
267     ?>
268
269     <script>
270         
// initial lookup values
271
272         jQuery(function() {
273             setTimeout(function(){
274             },
10); /* we need to slightly delay client-side execution of the above code to allow AppGini.ajaxCache to work */
275         });
276     </script>
277     <?php
278
279     $lookups = str_replace(
'__RAND__', $rnd1, ob_get_contents());
280     ob_end_clean();
281
282
283     
// code for template based detail view forms
284
285     
// open the detail view template
286     
if($dvprint){
287         $template_file = is_file(
"./{$TemplateDVP}") ? "./{$TemplateDVP}" : './templates/personal_time_table_templateDVP.html';
288         $templateCode = @file_get_contents($template_file);
289     }
else{
290         $template_file = is_file(
"./{$TemplateDV}") ? "./{$TemplateDV}" : './templates/personal_time_table_templateDV.html';
291         $templateCode = @file_get_contents($template_file);
292     }
293
294     
// process form title
295     $templateCode = str_replace(
'<%%DETAIL_VIEW_TITLE%%>', 'Chi tiết lịch cá nhân', $templateCode);
296     $templateCode = str_replace(
'<%%RND1%%>', $rnd1, $templateCode);
297     $templateCode = str_replace(
'<%%EMBEDDED%%>', ($_REQUEST['Embedded'] ? 'Embedded=1' : ''), $templateCode);
298     
// process buttons
299     
if($AllowInsert){
300         
if(!$selected_id) $templateCode = str_replace('<%%INSERT_BUTTON%%>', '<button type="submit" class="btn btn-success" id="insert" name="insert_x" value="1" onclick="return personal_time_table_validateData();"><i class="glyphicon glyphicon-plus-sign"></i> ' . $Translation['Save New'] . '</button>', $templateCode);
301         $templateCode = str_replace(
'<%%INSERT_BUTTON%%>', '<button type="submit" class="btn btn-default" id="insert" name="insert_x" value="1" onclick="return personal_time_table_validateData();"><i class="glyphicon glyphicon-plus-sign"></i> ' . $Translation['Save As Copy'] . '</button>', $templateCode);
302     }
else{
303         $templateCode = str_replace(
'<%%INSERT_BUTTON%%>', '', $templateCode);
304     }
305
306     
// 'Back' button action
307     
if($_REQUEST['Embedded']){
308         $backAction =
'AppGini.closeParentModal(); return false;';
309     }
else{
310         $backAction =
'$j(\'form\').eq(0).attr(\'novalidate\', \'novalidate\'); document.myform.reset(); return true;';
311     }
312
313     
if($selected_id){
314         
if(!$_REQUEST['Embedded']) $templateCode = str_replace('<%%DVPRINT_BUTTON%%>', '<button type="submit" class="btn btn-default" id="dvprint" name="dvprint_x" value="1" onclick="$$(\'form\')[0].writeAttribute(\'novalidate\', \'novalidate\'); document.myform.reset(); return true;" title="' . html_attr($Translation['Print Preview']) . '"><i class="glyphicon glyphicon-print"></i> ' . $Translation['Print Preview'] . '</button>', $templateCode);
315         
if($AllowUpdate){
316             $templateCode = str_replace(
'<%%UPDATE_BUTTON%%>', '<button type="submit" class="btn btn-success btn-lg" id="update" name="update_x" value="1" onclick="return personal_time_table_validateData();" title="' . html_attr($Translation['Save Changes']) . '"><i class="glyphicon glyphicon-ok"></i> ' . $Translation['Save Changes'] . '</button>', $templateCode);
317         }
else{
318             $templateCode = str_replace(
'<%%UPDATE_BUTTON%%>', '', $templateCode);
319         }
320         
if(($arrPerm[4]==1 && $ownerMemberID==getLoggedMemberID()) || ($arrPerm[4]==2 && $ownerGroupID==getLoggedGroupID()) || $arrPerm[4]==3){ // allow delete?
321             $templateCode = str_replace(
'<%%DELETE_BUTTON%%>', '<button type="submit" class="btn btn-danger" id="delete" name="delete_x" value="1" onclick="return confirm(\'' . $Translation['are you sure?'] . '\');" title="' . html_attr($Translation['Delete']) . '"><i class="glyphicon glyphicon-trash"></i> ' . $Translation['Delete'] . '</button>', $templateCode);
322         }
else{
323             $templateCode = str_replace(
'<%%DELETE_BUTTON%%>', '', $templateCode);
324         }
325         $templateCode = str_replace(
'<%%DESELECT_BUTTON%%>', '<button type="submit" class="btn btn-default" id="deselect" name="deselect_x" value="1" onclick="' . $backAction . '" title="' . html_attr($Translation['Back']) . '"><i class="glyphicon glyphicon-chevron-left"></i> ' . $Translation['Back'] . '</button>', $templateCode);
326     }
else{
327         $templateCode = str_replace(
'<%%UPDATE_BUTTON%%>', '', $templateCode);
328         $templateCode = str_replace(
'<%%DELETE_BUTTON%%>', '', $templateCode);
329         $templateCode = str_replace(
'<%%DESELECT_BUTTON%%>', ($ShowCancel ? '<button type="submit" class="btn btn-default" id="deselect" name="deselect_x" value="1" onclick="' . $backAction . '" title="' . html_attr($Translation['Back']) . '"><i class="glyphicon glyphicon-chevron-left"></i> ' . $Translation['Back'] . '</button>' : ''), $templateCode);
330     }
331
332     
// set records to read only if user can't insert new records and can't edit current record
333     
if(($selected_id && !$AllowUpdate && !$AllowInsert) || (!$selected_id && !$AllowInsert)){
334         $jsReadOnly .=
"\tjQuery('#day').replaceWith('<div class=\"form-control-static\" id=\"day\">' + (jQuery('#day').val() || '') + '</div>'); jQuery('#day-multi-selection-help').hide();\n";
335         $jsReadOnly .=
"\tjQuery('#time_start').replaceWith('<div class=\"form-control-static\" id=\"time_start\">' + (jQuery('#time_start').val() || '') + '</div>');\n";
336         $jsReadOnly .=
"\tjQuery('#time_end').replaceWith('<div class=\"form-control-static\" id=\"time_end\">' + (jQuery('#time_end').val() || '') + '</div>');\n";
337         $jsReadOnly .=
"\tjQuery('#activity').replaceWith('<div class=\"form-control-static\" id=\"activity\">' + (jQuery('#activity').val() || '') + '</div>');\n";
338         $jsReadOnly .=
"\tjQuery('.select2-container').hide();\n";
339
340         $noUploads =
true;
341     }elseif($AllowInsert){
342         $jsEditable .=
"\tjQuery('form').eq(0).data('already_changed', true);"; // temporarily disable form change handler
343         $jsEditable .=
"\tjQuery('#time_start').addClass('always_shown').timepicker({ defaultTime: false, showSeconds: true, showMeridian: true, showInputs: false, disableFocus: true, minuteStep: 5 });";
344         $jsEditable .=
"\tjQuery('#time_end').addClass('always_shown').timepicker({ defaultTime: false, showSeconds: true, showMeridian: true, showInputs: false, disableFocus: true, minuteStep: 5 });";
345             $jsEditable .=
"\tjQuery('form').eq(0).data('already_changed', false);"; // re-enable form change handler
346     }
347
348     
// process combos
349     $templateCode = str_replace(
'<%%COMBO(day)%%>', $combo_day->HTML, $templateCode);
350     $templateCode = str_replace(
'<%%COMBOTEXT(day)%%>', $combo_day->SelectedData, $templateCode);
351
352     
/* lookup fields array: 'lookup field name' => array('parent table name', 'lookup field caption') */
353     $lookup_fields = array();
354     
foreach($lookup_fields as $luf => $ptfc){
355         $pt_perm = getTablePermissions($ptfc[
0]);
356
357         
// process foreign key links
358         
if($pt_perm['view'] || $pt_perm['edit']){
359             $templateCode = str_replace(
"<%%PLINK({$luf})%%>", '<button type="button" class="btn btn-default view_parent hspacer-md" id="' . $ptfc[0] . '_view_parent" title="' . html_attr($Translation['View'] . ' ' . $ptfc[1]) . '"><i class="glyphicon glyphicon-eye-open"></i></button>', $templateCode);
360         }
361
362         
// if user has insert permission to parent table of a lookup field, put an add new button
363         
if($pt_perm['insert'] && !$_REQUEST['Embedded']){
364             $templateCode = str_replace(
"<%%ADDNEW({$ptfc[0]})%%>", '<button type="button" class="btn btn-success add_new_parent hspacer-md" id="' . $ptfc[0] . '_add_new" title="' . html_attr($Translation['Add New'] . ' ' . $ptfc[1]) . '"><i class="glyphicon glyphicon-plus-sign"></i></button>', $templateCode);
365         }
366     }
367
368     
// process images
369     $templateCode = str_replace(
'<%%UPLOADFILE(id)%%>', '', $templateCode);
370     $templateCode = str_replace(
'<%%UPLOADFILE(day)%%>', '', $templateCode);
371     $templateCode = str_replace(
'<%%UPLOADFILE(time_start)%%>', '', $templateCode);
372     $templateCode = str_replace(
'<%%UPLOADFILE(time_end)%%>', '', $templateCode);
373     $templateCode = str_replace(
'<%%UPLOADFILE(activity)%%>', '', $templateCode);
374
375     
// process values
376     
if($selected_id){
377         
if( $dvprint) $templateCode = str_replace('<%%VALUE(id)%%>', safe_html($urow['id']), $templateCode);
378         
if(!$dvprint) $templateCode = str_replace('<%%VALUE(id)%%>', html_attr($row['id']), $templateCode);
379         $templateCode = str_replace(
'<%%URLVALUE(id)%%>', urlencode($urow['id']), $templateCode);
380         
if( $dvprint) $templateCode = str_replace('<%%VALUE(day)%%>', safe_html($urow['day']), $templateCode);
381         
if(!$dvprint) $templateCode = str_replace('<%%VALUE(day)%%>', html_attr($row['day']), $templateCode);
382         $templateCode = str_replace(
'<%%URLVALUE(day)%%>', urlencode($urow['day']), $templateCode);
383         $templateCode = str_replace(
'<%%VALUE(time_start)%%>', time12(html_attr($row['time_start'])), $templateCode);
384         $templateCode = str_replace(
'<%%URLVALUE(time_start)%%>', urlencode(time12($urow['time_start'])), $templateCode);
385         $templateCode = str_replace(
'<%%VALUE(time_end)%%>', time12(html_attr($row['time_end'])), $templateCode);
386         $templateCode = str_replace(
'<%%URLVALUE(time_end)%%>', urlencode(time12($urow['time_end'])), $templateCode);
387         
if( $dvprint) $templateCode = str_replace('<%%VALUE(activity)%%>', safe_html($urow['activity']), $templateCode);
388         
if(!$dvprint) $templateCode = str_replace('<%%VALUE(activity)%%>', html_attr($row['activity']), $templateCode);
389         $templateCode = str_replace(
'<%%URLVALUE(activity)%%>', urlencode($urow['activity']), $templateCode);
390     }
else{
391         $templateCode = str_replace(
'<%%VALUE(id)%%>', '', $templateCode);
392         $templateCode = str_replace(
'<%%URLVALUE(id)%%>', urlencode(''), $templateCode);
393         $templateCode = str_replace(
'<%%VALUE(day)%%>', '', $templateCode);
394         $templateCode = str_replace(
'<%%URLVALUE(day)%%>', urlencode(''), $templateCode);
395         $templateCode = str_replace(
'<%%VALUE(time_start)%%>', time12(''), $templateCode);
396         $templateCode = str_replace(
'<%%URLVALUE(time_start)%%>', urlencode(time12('')), $templateCode);
397         $templateCode = str_replace(
'<%%VALUE(time_end)%%>', time12(''), $templateCode);
398         $templateCode = str_replace(
'<%%URLVALUE(time_end)%%>', urlencode(time12('')), $templateCode);
399         $templateCode = str_replace(
'<%%VALUE(activity)%%>', '', $templateCode);
400         $templateCode = str_replace(
'<%%URLVALUE(activity)%%>', urlencode(''), $templateCode);
401     }
402
403     
// process translations
404     
foreach($Translation as $symbol=>$trans){
405         $templateCode = str_replace(
"<%%TRANSLATION($symbol)%%>", $trans, $templateCode);
406     }
407
408     
// clear scrap
409     $templateCode = str_replace(
'<%%', '<!-- ', $templateCode);
410     $templateCode = str_replace(
'%%>', ' -->', $templateCode);
411
412     
// hide links to inaccessible tables
413     
if($_REQUEST['dvprint_x'] == ''){
414         $templateCode .=
"\n\n<script>\$j(function(){\n";
415         $arrTables = getTableList();
416         
foreach($arrTables as $name => $caption){
417             $templateCode .=
"\t\$j('#{$name}_link').removeClass('hidden');\n";
418             $templateCode .=
"\t\$j('#xs_{$name}_link').removeClass('hidden');\n";
419         }
420
421         $templateCode .= $jsReadOnly;
422         $templateCode .= $jsEditable;
423
424         
if(!$selected_id){
425         }
426
427         $templateCode.=
"\n});</script>\n";
428     }
429
430     
// ajaxed auto-fill fields
431     $templateCode .=
'<script>';
432     $templateCode .=
'$j(function() {';
433
434
435     $templateCode.=
"});";
436     $templateCode.=
"</script>";
437     $templateCode .= $lookups;
438
439     
// handle enforced parent values for read-only lookup fields
440
441     
// don't include blank images in lightbox gallery
442     $templateCode = preg_replace(
'/blank.gif" data-lightbox=".*?"/', 'blank.gif"', $templateCode);
443
444     
// don't display empty email links
445     $templateCode=preg_replace(
'/<a .*?href="mailto:".*?<\/a>/', '', $templateCode);
446
447     
/* default field values */
448     $rdata = $jdata = get_defaults(
'personal_time_table');
449     
if($selected_id){
450         $jdata = get_joined_record(
'personal_time_table', $selected_id);
451         
if($jdata === false) $jdata = get_defaults('personal_time_table');
452         $rdata = $row;
453     }
454     $templateCode .= loadView(
'personal_time_table-ajax-cache', array('rdata' => $rdata, 'jdata' => $jdata));
455
456     
// hook: personal_time_table_dv
457     
if(function_exists('personal_time_table_dv')){
458         $args=array();
459         personal_time_table_dv(($selected_id ? $selected_id : FALSE), getMemberInfo(), $templateCode, $args);
460     }
461
462     
return $templateCode;
463 }
464 ?>



Hệ thống xếp lịch học tín chỉ cho sinh viên CNTT trên PHP & MySQL 111.136 lượt xem

Gõ tìm kiếm nhanh...